package com.niit.web.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.niit.bean.User;
import com.niit.bean.UserInfo;
import com.niit.service.UserInfoService;
import com.niit.service.impl.UserInfoServiceImpl;

@WebServlet("/ShowMainPageByUser")
public class ShowMainPageByUser extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		User user = (User) request.getSession().getAttribute("user");
		UserInfoService uis = new UserInfoServiceImpl();
		UserInfo info = uis.findByUser(user);
		request.setAttribute("userinfo", info);
		request.getRequestDispatcher("/jsp/user/userhome.jsp").forward(request,
				response);
	}

}
